package eu.jozefsumaj.eis;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;

public class EIS_androidActivity extends Activity {
	
	WebView mWebView;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
    
    /** Called when the user selects the Scan QR button */
    public void scanQR(View view) {
    	Intent intent = new Intent("com.google.zxing.client.android.SCAN");
    	intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
    	startActivityForResult(intent, 0);
    }
    
    public void onActivityResult(int requestCode, int resultCode, Intent intent) {
	   if (requestCode == 0) {
	      if (resultCode == RESULT_OK) {
	         String contents = intent.getStringExtra("SCAN_RESULT");
	         //String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
	         
	         setContentView(R.layout.web);
	         mWebView = (WebView) findViewById(R.id.webview);
	         mWebView.getSettings().setJavaScriptEnabled(true);
	         mWebView.loadUrl(contents);
	         
	      } else if (resultCode == RESULT_CANCELED) {
	         // TODO. Handle cancel
	      }
	   }
	}
}